package xyz.xtt.asset.enums;

import java.util.Arrays;
import java.util.Objects;

import com.google.common.primitives.Ints;

/**
 * @author huqibo
 * 
 *         资产类型枚举
 */
public enum OrderTypeEnum {
	/**
	 * 正常订单
	 */
	NORMAL(0, "正常订单"),
	/**
	 * 收银台加购订单
	 */
	AFTER_ADD(1, "加购订单"),
	/**
	 * 铸造
	 */
	MINT(2, "铸造"),
	/**
	 * 铸造
	 */
	DIRECTIONAL(3, "定向解锁订单"),
	/**
	 * 活动
	 */
	ACTIVITY(3, "活动"),
	/**
	 * 个人铸造
	 */
	PERSONAL_MINT(5, "个人铸造"),
	/**
	 * 赠送
	 */
	GIFT(6, "赠送"),
	/**
	 * 1155协议商品购买
	 */
	BUY_ASSET_1155(7,"1155协议商品购买"),

	C_TO_C(10, "C2C交易"),
	ASSET_WITH_PHYSICAL(11,"拥有实物的数字资产交易"),
	/**
	 *　销毁
	 */
	BURN(12,"销毁"),
	ROSE_MINT(13,"玫瑰铸造"),
	;

	/**
	 * 编码
	 */
	private int code;
	/**
	 * 描述
	 */
	private String desc;

	OrderTypeEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int code() {
		return code;
	}

	public String desc() {
		return desc;
	}

	public static boolean checkType(String checkType) {
		return Arrays.asList(OrderTypeEnum.values()).stream().anyMatch(x -> Objects.equals(x.name(), checkType));
	}

	public static OrderTypeEnum convert(String checkType) {
		return Arrays.asList(OrderTypeEnum.values()).stream().filter(x -> Objects.equals(x.name(), checkType)).findFirst().orElse(null);
	}

	public static OrderTypeEnum queryConvert(String checkType) {
		return Arrays.asList(OrderTypeEnum.values()).stream().filter(x -> Objects.equals(x.code(), Ints.tryParse(checkType))).findFirst().orElse(null);
	}

	public static OrderTypeEnum queryConvert(int checkType) {
		return Arrays.asList(OrderTypeEnum.values()).stream().filter(x -> Objects.equals(x.code(), checkType)).findFirst().orElse(null);
	}

}
